package com.nx.vip.javacore.generic.type;

import org.junit.Test;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;


/**
 * 泛型并不一下那个像数据的基本类型
 * 伪泛型，Java编译期间会将泛型擦除
 */
public class GenType {

    @Test
    public void m01(){
        List list = new ArrayList();
        List<String> strList = new ArrayList<String>();

        System.out.println(list.getClass());
        System.out.println(strList.getClass());
        System.out.println(list.getClass()==strList.getClass()); //true?false?
    }

    @Test
    public void method02() throws Exception {
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
//        list.add(1);
        System.out.println(list.size());
        System.out.println("-------------------------");

        Class<? extends List> clazz = list.getClass();
        Method m = clazz.getDeclaredMethod("add", Object.class);
        m.invoke(list,new Object());

        System.out.println(list.size());

    }



}
